/* Layout */
import Layout from "@/views/layout";
// import Home from "@/views/Home/Index";
import Library from "@/views/library/Index";
import Rankings from "@/views/rankings/Index";
import Download from "@/views/download/Index";
import Feedback from "@/views/Home/feedback/Index";

/**
 * 主路由
 */
export const appRouter = [
  {
    path: "/",
    redirect: {
      name: "home",
    },
    meta: {
      title: "Home",
      keepAlive: true,
    },
    component: Layout,
    children: [
      {
        path: "home",
        name: "home",
        meta: {
          title: "Home",
          keepAlive: true,
        },
        component: () =>
          import(/* webpackChunkName: 'Home' */ "@/views/homepage/Index"),
      },
      {
        path: "book-detail/:id",
        name: "bookDetail",
        meta: {
          title: "bookDetail",
          update: true,
          keepAlive: false,
        },
        component: () =>
          import(/* webpackChunkName: 'Detail' */ "@/views/detail/book/Index"),
      },
      {
        path: "library",
        redirect: "library/female/all/all",
        name: "library",
        meta: {
          title: "Library",
          keepAlive: true,
        },
        component: Library,
        // component: () =>
        //   import(/* webpackChunkName: 'Library' */ "@/views/library/Index"),
        children: [
          {
            path: "/library/:sex/:genre/:state",
            name: "libraryView",
            meta: {
              title: "Library",
              update: true,
              keepAlive: true,
            },
            component: () =>
              import(/* webpackChunkName: 'Library' */ "@/views/library/Index"),
          },
        ],
      },
      {
        path: "rankings",
        redirect: "rankings/null",
        name: "rankings",
        meta: {
          title: "Rankings",
          keepAlive: true,
        },
        component: Rankings,
        // component: () =>
        //   import(/* webpackChunkName: 'Rankings' */ "@/views/rankings/Index"),
        children: [
          {
            path: "/rankings/:title",
            name: "rankingsView",
            meta: {
              title: "Rankings",
              keepAlive: true,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Rankings' */ "@/views/rankings/detail/Index"
              ),
          },
        ],
      },
      {
        path: "download",
        redirect: "download/default",
        name: "download",
        meta: {
          title: "Download",
          keepAlive: true,
        },
        component: Download,
        children: [
          {
            path: "/download/:msg",
            name: "downloadApp",
            meta: {
              title: "DownloadApp",
              keepAlive: true,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Download' */ "@/views/download/Index"
              ),
          },
        ],
      },
      {
        path: "search/:keywords",
        name: "search",
        meta: {
          title: "Search",
          update: true,
          keepAlive: true,
        },
        component: () =>
          import(
            /* webpackChunkName: 'Search' */ "@/views/detail/search/Index"
          ),
      },
      //全局页面
      {
        path: "/reader/:id",
        name: "reader",
        meta: {
          title: "Reader",
          keepAlive: true,
          global: true,
        },
        component: () =>
          import(/* webpackChunkName: 'Home' */ "@/views/reader/Index"),
      },
      {
        path: "/premium",
        name: "premium",
        meta: {
          title: "Premium",
          keepAlive: true,
          global: true,
        },
        component: () =>
          import(/* webpackChunkName: 'Home' */ "@/views/Home/premium/Index"),
      },
      {
        path: "/myAccount",
        name: "myAccount",
        meta: {
          title: "MyAccount",
          keepAlive: true,
          global: true,
        },
        component: () =>
          import(/* webpackChunkName: 'Home' */ "@/views/Home/myAccount/Index"),
      },
      {
        path: "/bookEnd/:bookId",
        name: "bookEnd",
        meta: {
          title: "BookEnd",
          keepAlive: true,
          global: true,
        },
        component: () =>
          import(/* webpackChunkName: 'Home' */ "@/views/Home/bookEnd/Index"),
      },
      {
        path: "/bookshelf",
        name: "bookshelf",
        meta: {
          title: "Bookshelf",
          keepAlive: true,
          global: true,
        },
        component: () =>
          import(/* webpackChunkName: 'Home' */ "@/views/Home/bookshelf/Index"),
      },
      {
        path: "/reading-history",
        name: "reading-history",
        meta: {
          title: "Reading History",
          keepAlive: true,
          global: true,
        },
        component: () =>
          import(
            /* webpackChunkName: 'Home' */ "@/views/Home/readingHistory/Index"
          ),
      },
      {
        path: "/feedback",
        name: "feedback",
        meta: {
          title: "Feedback",
          keepAlive: true,
          global: true,
        },
        component: Feedback,
        children: [
          {
            path: "send-feedback",
            name: "sendFeedback",
            meta: {
              title: "Send Feedback",
              keepAlive: true,
              global: true,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Feedback' */ "@/views/Home/feedback/sendFeedBack/Index"
              ),
          },
          {
            path: "my-feedback",
            name: "myFeedback",
            meta: {
              title: "My Feedback",
              keepAlive: true,
              global: true,
            },
            component: () =>
              import(
                /* webpackChunkName: 'Feedback' */ "@/views/Home/feedback/myFeedback/Index"
              ),
          },
        ],
      },
    ],
  },
];

export const routes = [...appRouter];
